<style>
    #obj-add {
        padding: 20px 25px 25px 0;
    }
    #obj-add .layui-treeSelect .ztree li a, .ztree li span {
        margin: 0 0 2px 3px !important;
    }
</style>
<div class="layui-fluid" id="obj-add">
    <form class="layui-form" action="" lay-filter="obj-add-form">
                <div class="layui-form-item">
                    <label class="layui-form-label febs-form-item-require">业务id：</label>
                    <div class="layui-input-block">
                        <select name="bussIds"
                                lay-verify="required"
                                xm-select-direction="down"
                                xm-select="conn-add"
                                xm-select-search="/menuItemFile/all"
                                xm-select-search-type="dl"
                                xm-select-skin="default">
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">大项：</label>
                    <div class="layui-input-block">
                        <select name="menuId" id="menuId" >

                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">表名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="bussTableName" class="layui-input" value="menu_item_file">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">业务类型：</label>
                    <div class="layui-input-block">
                        <input type="text" name="bussType" class="layui-input" >
                    </div>
                </div>

        <div class="layui-form-item febs-hide">
            <button class="layui-btn" lay-submit="" lay-filter="obj-add-form-submit" id="submit"></button>
            <button type="reset" class="layui-btn" id="reset"></button>
        </div>
    </form>
</div>

<script>
    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect'], function () {
        var $ = layui.$,
            febs = layui.febs,
            layer = layui.layer,
            formSelects = layui.formSelects,
            treeSelect = layui.treeSelect,
            form = layui.form,
            $view = $('#obj-add'),
            validate = layui.validate;

        form.verify(validate);
        form.render();

        formSelects.render();
        $.get(ctx+"menuTitle/data",{},function (data) {
            var list=data.data
            var select = document.getElementById('menuId');
            if (list != null || list.size() > 0) {
                for (var c =0;c<list.length;c++) {
                    var option = document.createElement("option");
                    option.setAttribute("value", list[c].id);
                    option.innerText = list[c].name;
                    select.appendChild(option)
                }
            }
            layui.form.render("select");
        },"json");
        formSelects.config('conn-add', {
            searchUrl: 'menuItemFile/all',
            response: {
                statusCode: 200
            },
            beforeSuccess: function (id, url, searchVal, result) {
                var data = result.data;
                var tranData = [];
                for (var i = 0; i < data.length; i++) {
                    tranData.push({
                        name: data[i].realName,
                        value: data[i].id
                    })
                }
                result.data = tranData;
                return result;
            },
            error: function (id, url, searchVal, err) {
                console.error(err);
                febs.alert.error('失败');
            }
        });
        form.on('submit(obj-add-form-submit)', function (data) {
            febs.post(ctx + 'menuItemConn', data.field, function () {
                layer.closeAll();
                febs.alert.success('新增成功');
                $('#febs-obj').find('#query').click();
            });
            return false;
        });
    });
</script>